﻿#include "sort.h"

// 冒泡排序
void bubbleSort(std::vector<int>& data) 
{
	for (size_t i = 0; i < data.size(); ++i) 
	{
		for (size_t j = 0; j < data.size() - i - 1; ++j) 
		{
			if (data[j] > data[j + 1]) 
			{
				std::swap(data[j], data[j + 1]);
			}
		}
	}
}

//快速排序
void quickSort(std::vector<int>& data, int left, int right) 
{
	if (left >= right) 
		return;
	int pivot = data[left];
	int i = left, j = right;
	while (i < j) 
	{
		while (i < j && data[j] >= pivot) 
			--j;
		data[i] = data[j];
		while (i < j && data[i] <= pivot) 
			++i;
		data[j] = data[i];
	}
	data[i] = pivot;
	quickSort(data, left, i - 1);
	quickSort(data, i + 1, right);
}

//标准库排序
void stdSort(std::vector<int>& data) {
	std::sort(data.begin(), data.end());
}